import UICore from "../../../../Core/Res/UICore";
import { GameModels } from "../../socket/GameModels";
import AbstractUIWindow from "../../window/AbstractUIWindow";

import * as fgui from "fairygui-cc";

export class TestWindow extends AbstractUIWindow {
    private addexp: fgui.GButton;
    private addcoin: fgui.GButton;
    private addd: fgui.GButton;
    private addp: fgui.GButton;
    private addpet: fgui.GButton;
    private petinput: fgui.GTextInput;
    protected getResList(): Array<string> {
        return ["Common"];
    }
    protected onInit(): void {
        this._view = UICore.createObject("Common", "TestWindow").asCom;
    }
    protected onShow(): void {
        this.addexp.onClick(this.clickaddexp, this);
        this.addcoin.onClick(this.clickaddcoin, this);
        this.addd.onClick(this.clickaddd, this);
        this.addp.onClick(this.clickaddp, this);
        this.addpet.onClick(this.clickaddpet, this);
    }
    private clickaddpet(): void {
        if (!this.petinput.text) {
            return;
        }
        GameModels.login.sendGmReq(`addpet ${this.petinput.text}`);
    }
    private clickaddp(): void {
        GameModels.login.sendGmReq(`addpower 100`);
    }
    private clickaddd(): void {
        GameModels.login.sendGmReq(`adddiamond 10000`);
    }
    private clickaddcoin(): void {
        GameModels.login.sendGmReq(`addcoin 100000`);
    }
    private clickaddexp(): void {
        GameModels.login.sendGmReq(`addexp 1000`);
    }
    protected onClose(): void {

    }
}